﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using QxFramework.Core;
using UnityEngine.UI;
public class OperationPanel : UIBase
{
    GameObject start;
    GameObject next;
    GameObject home;
    GameObject save;
    private void Awake()
    {
        start = transform.Find("Start").gameObject;
        next = transform.Find("Bag").gameObject;
        home = transform.Find("Home").gameObject;
        save = transform.Find("Save").gameObject;

        start.GetComponentInChildren<Button>().onClick.SetListener(() =>
        {
            MessageManager.Instance.Get<GameControl.GameAction>().DispatchMessage(GameControl.GameAction.QuitBenchUI, this, new BenchArgs
            {
                user = GameControl.GameManager.Instance.User,
                benchName = CombineUI.Instance.BenchName
            }) ;
        });
  /*      next.GetComponentInChildren<Button>().onClick.SetListener(() =>
        {
            UIManager.Instance.Open("DialogWindowUI", 5, args: new DialogWindowUI.DialogWindowUIArg
      ("注意", "确定要离开当前关卡吗?\n不在拼装台上的物体都会被销毁", null, "确定","取消", () => {
          MessageManager.Instance.Get<GameControl.GameAction>().DispatchMessage(GameControl.GameAction.EndCurrentLevel, this,null);
      }));

        });*/
        home.GetComponentInChildren<Button>().onClick.SetListener(() =>
        {
            UIManager.Instance.Open("DialogWindowUI", 5, args: new DialogWindowUI.DialogWindowUIArg
      ("注意", "确定要回到主界面吗?\n没有保存的内容都会丢失", null, "确定", "取消", () => {
          MessageManager.Instance.Get<GameControl.GameAction>().DispatchMessage(GameControl.GameAction.ReturnToHome, this, null);
      }));

        });
        save.GetComponentInChildren<Button>().onClick.SetListener(() =>
        {
            UIManager.Instance.Open("DialogWindowUI", 5, args: new DialogWindowUI.DialogWindowUIArg
      ("注意", "确定要保存吗?\n将会覆盖之前的存档", null, "确定", "取消", () => {
          MessageManager.Instance.Get<GameControl.GameAction>().DispatchMessage(GameControl.GameAction.Save, this, null);
      }));

        });
    }
}
